* formal_graph.do	JEP	01/27/15
* Build regression table
* Formal sector, wages
*************************** Change log ********************************** 

/*
	
*/	

clear 
version 13.1

* Project info
cap project, doinfo
if _rc==198 {
	if c(username)=="J16339" loc master "B:\Col_Minimum_Wage" 
	else if c(username)=="A15858" loc master "B:\Col_Minimum_Wage"
	else if c(os)=="Windows" loc master "C:/Users/jorpp/Dropbox (Brown)/Col_Minimum_Wage"
	else loc master "/home/jperez/AA_Minimum_Wage"
	loc pr=0
}
else {
	local master "`r(pdir)'"
	local doname "`r(dofile)'" 
	* Project calls
	project, relies_on("`master'/Code/Est/rifregtable2.do")
	project, relies_on("`master'/Code/Est/graph_rif.do")
	/*
	foreach x in 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 {
		project, uses("`master'/Ster/rif4_new_med_indcc/reg_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster")
		project, uses("`master'/Ster/rif4_new_ebite_indcc/reg_emp_bp_tq(1999q1)_ebite_salario_mensual_real_50_edom_indcc_p`x'.ster")
		project, uses("`master'/Ster/rif4_new_indcc/reg_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster")
	}
	*/
	loc pr=1
}
foreach x in 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 {

	* Copy the needed files to a single folder
	copy "`master'/Ster/rif4_new_indcc/reg_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster" "`master'/Ster/eoy/reg_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster" , replace

	copy "`master'/Ster/rif4_new_indcc/reg_emp_bp_tq(1998q1)_ejercicio3_p`x'.ster" "`master'/Ster/eoy/reg_emp_bp_tq(1998q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster" , replace

	copy "`master'/Ster/rif4_new_indcc/reg_emp_bp_tq(1997q1)_ejercicio3_p`x'.ster" "`master'/Ster/eoy/reg_emp_bp_tq(1997q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster" , replace 
}

do "`master'/Code/Est/graph_rif.do"

cap program drop mex
program define mex
	cap mkdir "`2'/Doc"
	cap mkdir "`2'/Doc/tosubmit2"
	cap mkdir "`2'/Doc/tosubmit2/fig"
	graph export "`2'/Doc/tosubmit2/fig/`1'.pdf", replace	
	graph export "`2'/Doc/tosubmit2/fig/`1'.png", replace	
	graph export "`2'/Doc/tosubmit2/ILR-Figs/FigB4_`1'.png", replace	
end	


graph drop _all
glo qtiles "5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90"
set scheme s1color
loc i=1
foreach spec in /*reg_emp_bp reg_emp_bq */ reg_emp_bp {
	if `i'!=1 loc leg "legend(off)"
	if "`spec'"=="reg_emp_bp" loc subt "Bartik price shocks"
	if "`spec'"=="reg_emp_bq" loc subt "Bartik quantity shocks"
	if "`spec'"=="reg_sst_emp_bp" loc subt "Bartik price shocks - City trends"
	if "`spec'"=="reg_emp_bp_ixc" loc subt "Bartik price shocks - City x Industry FE"
	if "`spec'"=="reg_sst_emp_bq" loc subt "Bartik quantity shocks - City trends"
	if "`spec'"=="reg_emp_bq_ixc" loc subt "Bartik quantity shocks - City x Industry FE"
	
	else loc leg "legend(label(2 "UQE") label(1 "95 % CI"))"
	graphrif, master("`master'") ster(Ster) folder(eoy) qtiles($qtiles) spec(`spec') time(tq(1998q1)) rareaopts(fcolor(gs13) lcolor(none) lpattern(dash) ) twowayopts( xtitle(Percentile) ytitle(Coefficient) yscale(range(-0.0125 0.005)) xscale(range(5 90)) ylabel(-0.0125(0.0025)0.005, angle(horizontal)) legend(off) name(g`i'), (pci -0.0125 17 0.005 17, lcolor(black)) (pci -0.0125 32 0.005 32, lcolor(cranberry) lpattern(dash)))   lineopts(lcolor(black) xlab(10(10)90))
	loc i=`i'+1
}

graph play "`master'/Code/Doc/tosubmit2/formal_rob_eoy_97_98.grec"

mex formal_rob_eoy_97_98 "`master'"

if `pr' project, creates("`master'/Doc/tosubmit2/fig/formal_rob_eoy_97_98.pdf")



graph drop _all
glo qtiles "5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90"
set scheme s1color
loc i=1
foreach spec in /*reg_emp_bp reg_emp_bq */ reg_emp_bp {
	if `i'!=1 loc leg "legend(off)"
	if "`spec'"=="reg_emp_bp" loc subt "Bartik price shocks"
	if "`spec'"=="reg_emp_bq" loc subt "Bartik quantity shocks"
	if "`spec'"=="reg_sst_emp_bp" loc subt "Bartik price shocks - City trends"
	if "`spec'"=="reg_emp_bp_ixc" loc subt "Bartik price shocks - City x Industry FE"
	if "`spec'"=="reg_sst_emp_bq" loc subt "Bartik quantity shocks - City trends"
	if "`spec'"=="reg_emp_bq_ixc" loc subt "Bartik quantity shocks - City x Industry FE"
	
	else loc leg "legend(label(2 "UQE") label(1 "95 % CI"))"
	graphrif, master("`master'") ster(Ster) folder(eoy) qtiles($qtiles) spec(`spec') time(tq(1997q1)) rareaopts(fcolor(gs13) lcolor(none) lpattern(dash) ) twowayopts( xtitle(Percentile) ytitle(Coefficient) yscale(range(-0.02 0.015)) xscale(range(5 90)) ylabel(-0.02(0.005)0.015, angle(horizontal)) legend(off) name(g`i'), (pci -0.02 25 0.015 25, lcolor(black)) (pci -0.02 34 0.015 34, lcolor(cranberry) lpattern(dash)))   lineopts(lcolor(black) xlab(10(10)90))
	loc i=`i'+1
}

graph play "`master'/Code/Doc/tosubmit2/formal_rob_eoy_96_97.grec"

mex formal_rob_eoy_96_97 "`master'"

if `pr' project, creates("`master'/Doc/tosubmit2/fig/formal_rob_eoy_96_97.pdf")

